<template>
    <div class="recommend">
        <div class="title">
            <van-divider dashed
                :style="{ color: '#ee0a24', borderColor: '#ee0a24', padding: '0 16px' }">火爆推荐</van-divider>
        </div>
        <ul>
            <li v-for="(item, index) in recomList" :key="index"
            @click="goDetail(item.g_id)">
                <van-card 
                tag="火爆" 
                :price='item.g_price' 
                :desc="item.g_content" 
                :title="item.g_name"
                :thumb="item.imgUrl"  />
            </li>
        </ul>
    </div>
</template>

<script>
import {getGoods} from "@/api/goods/getgoods"

export default {
    data() {
        return {
            recomList: []
        }
    },


    created() {
        this.getRecommendList();
    },
    methods:{
        goDetail(id) {
            this.$router.push({path: '/detail', query: {id: id}})
            window.scrollTo(0, 0);
        },


        async getRecommendList() {
            const res = await getGoods()
            // console.log(res);
            
            if (res.status === 200){
                this.recomList = res.data
            }else{
                console.log("获取推荐商品失败")
            }
        }
    }
}
</script>

<style scoped>
.van-card{
    padding-top: 22px;
    width: 100%;
    font-size: 18px;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.07);
} 
.van-card__price-integer{
    font-size: 24px;
    color: rgb(216, 22, 22);
    padding-left: 4px;
}
.van-card__title{
    line-height: 24px;
}
.van-divider{
    font-size: 24px;
    font-weight: bold;
}

.van-image_img{
    width: 90px;
    height: 90px;
}

</style>